<template>
	<view class="parent-view">
		<text class="yingfu-txt">应付金额</text>
		<text class="jine-txt">￥298</text>
		<text class="fangshi-txt">支付方式</text>
		<view class="fangshi-view">
			<image class="weixin-icon" src="../../static/wx.png"></image>
			<text class="weixin-txt">微信支付</text>
		</view>
		<text class="zhifu-txt" @click="pay">确认支付 ￥298</text>
	</view>
</template>

<script>
	import request from '../index/request.js';
	export default {
		data() {
			return {
			}
		},
		methods: {
			onLoad: function(options) {
				this.appUtil.saveAppInviteId(options)
			},
			onShow:function(){
				this.share.url= '/pages/tabBar/home/index?appInviteId='+this.appUtil.getAppInviteId()
				this.share.shareType=1
			},
			pay:function(){
				var that = this
				request.post("api/user/VIP_oreder_pay", {
					goodsid:10,
					type:'miniapp',
					openid:uni.getStorageSync("shiqin-user-openId")
				}).then(data => {
					wx.requestPayment({
						provider: 'wxpay',
						timeStamp: data.timeStamp,
						nonceStr: data.nonceStr,
						package: data.package,
						paySign: data.paySign,
						signType: data.signType,
						success: function (res) {
							uni.showToast({
								title: '支付成功',
								icon: 'none',
								mask: true,
								duration: 1000
							});
						},
						fail: function (err) {
							console.log('fail:' + JSON.stringify(err));
							uni.showToast({
								title: '支付失败',
								icon: 'none',
								mask: true,
								duration: 1000
							});
						}
					});
				})
			}
		}
	}
</script>

<style>
	@import "index.css";
</style>
